package com.example.wxpay.controller;

import com.example.wxpay.api.WXPayUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.Map;

@Controller
public class WXPayController {

    @PostMapping("/pay")
    public String pay(ModelMap map,String orderNo,String body,String price) throws Exception {
        WXPayUtils wxPayUtils = new WXPayUtils();

        Map<String, String> rs = wxPayUtils.wxPay("http://127.0.0.1:80/callback",orderNo,String.valueOf(price),"192.168.1.1",body,"123456");
        System.out.println("=================微信统一下单，获取的微信返回结果====================");
        System.out.println(rs);

        map.put("code_url",rs.get("code_url"));
        return "/paycode";
    }

}
